﻿using BL;
using Entities;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class frmDangNhap : Form
    {
        TaiKhoanBL taiKhoanBL;

        public frmDangNhap()
        {
            InitializeComponent();
            taiKhoanBL = new TaiKhoanBL();
        }

        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            QuanLyTaiKhoan.taiKhoanHienTai = taiKhoanBL.kiemTraTaiKhoan(txtTaiKhoan.Text, txtMatKhau.Text);
            if (QuanLyTaiKhoan.taiKhoanHienTai != null)
            {
                QuanLyTaiKhoan.phanTichQuyen();

                QuanLyDonHang frmQLDH = new QuanLyDonHang();
                frmQLDH.Show();
                this.Hide();
            }
        }

        private void btnCauHinhServer_Click(object sender, EventArgs e)
        {
            frmConfig frm = new frmConfig();
            frm.Show();
        }

        private void frmDangNhap_Load(object sender, EventArgs e)
        {
            btnCauHinhServer.Visible = false;

        }

        private void txtMatKhau_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Return)
            {
                if (txtTaiKhoan.Text.Equals(Constant.CONST_USERNAME_DEFAULT_OPEN_CONFIG) &&
                    txtMatKhau.Text.Equals(Constant.CONST_PASSWORD_DEFAULT_OPEN_CONFIG))
                {
                    btnCauHinhServer.Visible = true;
                }
            }
        }
    }
}
